
<?php
form_head("admin/order_add".$type_id, "");?>
  <?php 
  $user = $this->user->get();
  text_field("firstname","ชื่อผู้ทำการสั่งซื้อ",array("firstname"=>$user["firstname"]." ".$user["lastname"]),1); ?>

     <?php area_field("remark","หมายเหตุ",null,1); ?>
     <?php 

		 $rows =  $this->db->query("select budget_id, concat(budget_name,'-', year) as budget_name from budgets")->result_array();

		 select_field("budget_id","ชนิดงบประมาณ",$rows,"budget_name","โปรดเลือก",0,null,"",2); 

	
		 ?>
		 
		      	<?php 

		 $rows =  $this->db->query("select company_id,concat(company_name,'')as company_name from company")->result_array();

		 select_field("company_id","บริษัทจัดหา",$rows,"company_name","โปรดเลือก",0,null,"",2); 

		 ?>
 <br/>
 ราการสั่งซื้อดังนี้ 
<table class="list" >

<thead>
	<th>ลำดับ</th>
	<th>ชื่อ</th>
	<th>รายละเอียดเพิ่มเติม</th>
	<th>จำนวน</th>
	<th>ราคาต่อหน่วย</th>
	
</thead>


<?php 

 $cat_text = $this->session->userdata("cat_temp_ids"); 
 //print_r($cat_text);
$cats= json_decode($cat_text);
//print_r($cats);
$no = 1;
for($i=0;$i<count($cats);$i++){
//print_r($cats[$i]->category_id);
$this->db->where("category_id",$cats[$i]->category_id);
$rows =$this->db->get("category_views")->result_array();
$row = $rows[0];

//print_r($rows);

?>
<tr>
	<td><?php echo $no++; ?></td>
	<td><?php  echo $row["category_name"];  ?></td>
	<td><input class="detail" type="text" name="detail_<?php echo $row["category_id"]; ?>" value="<?php if(isset($cats[$i]->detail)){echo $cats[$i]->detail;} ?>" /></td>
	<td><input class="amount" type="text" value="<?php echo $cats[$i]->amount; ?>" name="amount_<?php echo $row["category_id"]; ?>" /></td>
	<td><input class="price" type="text" name="price_<?php echo $row["category_id"]; ?>" /></td>
	<td></td>
	

</tr>

<?php  }  ?>


</table> 



<a href="javascript:void(0);" onclick="open_category();" >เลือก</a>  



<div class="claner"></div>

<?php form_footer(); ?>

<a href="<?php echo site_url("admin/order_reset/".$type_id); ?>">รีเซตข้อมูล</a>
<script type="text/javascript">

function open_category()
{
	PopupCenter("<?php echo site_url("admin/category_popup/".$type_id); ?>", "",400,600);
}

</script>
<style>

input.detail
{
width: 250px;
}
input.amount
{
width: 30px;
}
input.price
{
	width: 40px;
}
.sumprice
{
	float:right;
}

</style>
